#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QFont>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);


    QFont font;
    //设置文字字体
    font.setFamily("宋体");
    //设置文字大小为50像素
    font.setPixelSize(50);


    QString str = tr("<span style='background-color:red'>%1</span>").arg("错误的"); // 输入错误

    str = str.append("<span style='background-color:#ccc'>正确的</span>");
    str = str.append("<span style='background-color:red'>错误的</span>");
    qDebug() << "content" <<str;

    ui->textEdit->setHtml(str);
    ui->textEdit->setFont(font);
//    ui->textEdit->setStyleSheet(QString::fromUtf8 ("background-color:red"));
}

Widget::~Widget()
{
    delete ui;
}

QString Widget::setFontColor(QString str) {

    QString value = "";
    QString text;
    if (str == "error") {
        text = tr("<span style='background-color:red'>%1</span>").arg("错误的");
    }
    return "";
}
